import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/login',
    method: 'post',
    data
  })
}
// 注册
export function signUp(data) {
  return request({
    url: '/user/signUp',
    method: 'post',
    data
  })
}
// 重置密码
export function resetPass(data) {
  return request({
    url: '/user/resetPass',
    method: 'post',
    data
  })
}
export function getInfo(token) {
  return request({
    url: '/getUserInfo',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/logout',
    method: 'post'
  })
}
export function UpdateUser(username, password, newPassword, reNewPassword) {
  return request({
    url: '/vue-admin-template/user/UpdateUser',
    method: 'post',
    data: {
      username: username,
      password: password,
      newPassword: newPassword,
      reNewPassword: reNewPassword
    }
  })
}
export function updateInfo(username, name, introduction) {
  return request({
    url: '/vue-admin-template/user/updateInfo',
    method: 'post',
    data: {
      username: username,
      name: name,
      introduction: introduction
    }
  })
}
export function updateing(username, imageUrl) {
  return request({
    url: '/vue-admin-template/user/updateing',
    method: 'post',
    data: {
      username: username,
      avatar: imageUrl
    }
  })
}
// 游客登录

export function loginWithoutAuth(data) {
  return request({
    url: '/loginWithoutAuth',
    method: 'get',
    data
  })
}
// 用户分页列表
export function getUser(data) {
  return request({
    url: '/user/select',
    method: 'post',
    data: data
  })
}
// 添加用户

export function saveUser(data) {
  return request({
    url: '/user/save',
    method: 'post',
    data: data
  })
}
// 更新用户
export function update(data) {
  return request({
    url: '/user/update',
    method: 'post',
    data: data
  })
}
// 删除用户
export function deleteUser(data) {
  return request({
    url: '/user/delete',
    method: 'post',
    data
  })
}
// 修改密码

export function changePass(data) {
  return request({
    url: '/user/changePass',
    method: 'post',
    data
  })
}
// 修改用户权限
export function changeRole(data) {
  return request({
    url: '/user/changeRole',
    method: 'post',
    data
  })
}
// 批量导入用户

export function saveExcel(data) {
  return request({
    url: '/user/saveExcel',
    method: 'post',
    data
  })
}
// 模板下载

export function excelTemplate() {
  return request({
    url: '/user/excelTemplate',
    method: 'get',
  })
}
// 发送验证码至邮箱
export function getCode(data) {
  return request({
    url: '/user/getCode',
    method: 'get',
    params:data
  })
}
// 更换邮箱

export function changeEmail(data) {
  return request({
    url: '/user/changeEmail',
    method: 'post',
    data
  })
}
// 用户名获取验证码

export function getCodeByUsername(data) {
  return request({
    url: '/user/getCodeByUsername',
    method: 'get',
    params:data
  })
}